<template>
	<view>
		<Home v-show="current == 0" />
		<Haibao v-show="current == 1"></Haibao>
		<My v-show="current == 2" :info="info" :listArr="listArr" />
		
		<u-tabbar v-model="current" :list="list" ></u-tabbar>
	</view>
</template>
<script>
	import Home from './Home.vue';
	import My from './My.vue';
	import Haibao from "./Haibao.vue"
	
	import storage from '@/utils/storage.js';
	import { saleHome, saleComment } from '@/api/fenxiao.js'
	export default {
		components: {
			Home,
			My,
			Haibao
		},
		onReachBottom(){
		  // 给子级监听触底加载
		  if(this.current == 2){
			  this.page ++;
			  this.saleComment()
		  }

		},
		
		onLoad(option) {
			if(option.current){
				this.current = option.current
			}
		},
		
		onShow() {
			saleHome({
				id: storage.getUserInfo().storeId
			}).then(res => {
				this.info = res.data
			});
			this.page == 1;
			this.saleComment()
		},
		
		methods: {
			saleComment(){
				saleComment({
					id: storage.getUserInfo().storeId,
					page: this.page,
					limit: this.limit
				}).then(res=> {
					if(res.code == '000000'){
						this.listArr = [...this.listArr, ...res.data.list]
					}
				})
			},
		},
		
		data() {
			return {
				list: [{
						iconPath: "/static/tabbar/home.png",
						selectedIconPath: "/static/tabbar/home-s.png",
						text: '首页',
					},
					{
							iconPath: "/static/tabbar/haibaoguanli.png",
							selectedIconPath: "/static/tabbar/haibaoguanli_select.png",
							text: '海报管理',
						},
					{
					iconPath: "/static/tabbar/mine.png",
					selectedIconPath: "/static/tabbar/mine-s.png",
						text: '我的',
					},
				],
				current: 0,
				info: {},
				page: 1,
				limit: 10,
				listArr: []
			}
		},
	}
</script>

